package com.demonzym.data.infos;

import java.util.ArrayList;
import java.util.Iterator;


public class DiKouQuan {
	public String id, zhuid, jiaqian;
	public static DiKouQuan parse(String d){
		DiKouQuan dkq = new DiKouQuan();
		String[] data = d.split("[&]");
		dkq.id = data[0];
		dkq.zhuid = data[1];
		dkq.jiaqian = data[2];
		return dkq;
	}
	public static DiKouQuan[] parse(String[] d){
		DiKouQuan[] dkq = new DiKouQuan[d.length];
		for(int i = 0; i < d.length; i++){
			dkq[i] = parse(d[i]);
		}
		return dkq;
	}
	public static String[] toStringArray(DiKouQuan[] dkq){
		String[] s = new String[dkq.length];
		for(int i = 0; i < dkq.length; i++){
			s[i] = dkq[i].id + " " + dkq[i].jiaqian;
		}
		return s;
	}
	public static String toString(ArrayList<DiKouQuan> dkq){
		Iterator<DiKouQuan> iterator = dkq.iterator();
		String s = new String();
		s += String.valueOf(dkq.size());
		while(iterator.hasNext()){
			s += "|" + iterator.next().id;
		}
		return s;
	}
	
	public static String getSum(ArrayList<DiKouQuan> dkq){
		Iterator<DiKouQuan> iterator = dkq.iterator();
		int sum = 0;
		while(iterator.hasNext()){
			sum += Integer.parseInt(iterator.next().jiaqian);
		}
		return String.valueOf(sum);
	}
}
